Skip to content

Kconfig: evaluate compiler-selected Kbuild dynamically with map_directory - #83

Draft
fionera wants to merge 46 commits into
hermeticbuild:mainfrom
fionera:agent/map-directory-kconfig-spike
Draft

fionera wants to merge 46 commits into
hermeticbuild:mainfrom
fionera:agent/map-directory-kconfig-spike

Conversation

@fionera

@fionera fionera commented Aug 11, 2026 •

Copy link
Copy Markdown
Collaborator

Current checkpoint — planner/query fidelity, 2026-09-12 17:31 UTC

Commit 9448c08212f5cd38ed7bf9a808d17372432bb170. Still draft; not ready to merge. No merge/release, gate relaxation, compiler-flag normalization, or new output bases. Local validation uses CI RBE with disk cache disabled.

Changes in this checkpoint

  • Lossless v5 compiler-guard string dictionaries reduce repeated argv/environment transport while preserving exact context/query identities and the existing compact/wire/expanded budgets.
  • Preserve source-selected non-compiler helper lines and rooted compiler-probe argument provenance in compound ARM recipes.
  • Share immutable producer-adjacency reads within one traversal, and identical side-output projections within one planning phase.
  • Observe ordinary transitive outputs from the already executed generator cut, retaining existing source/owner and final-cut verification.
  • Add compiler-measured __has_feature/__has_extension grammar support, requested defined operands, and earlier literal-defined(...) inventory queries. Source syntax supplies questions, never capability values.
  • Add the bounded kbuild_cpu_profile diagnostic output group; update the README.

Verified results and qualification limits

  • Current commit: 177/177 locally runnable root tests pass on Bazel 9.2.0 and 9.1.0. Only the local source-repository test is excluded because it creates nondefault nested output roots; CI retains it.
  • Immediately before the final initial-inventory addition: the actual ARM/Clang artifact and external-module batch passes 3/3 on 9.2.0 and 9.1.0. These build kernel/vmlinux/zImage/modules and check ARM ELF/image contents; they are not QEMU boot tests.
  • The same pre-inventory source passes all four actual GCC/9.2.0 family targets, taking 2,874.302s (47m54s). The unchanged reuse gate fails: 140 reused instances versus baseline 155; 1.78% versus 1.97%.
  • Base/LZ4 now share 26/1,240 compiler nodes, versus 2/1,240 in the retained GCC baseline. The other five config pairs still share no compiler nodes. Compared with that baseline there are 24 fewer unique compiler nodes, 27 more unique copy/generator nodes, and four fewer unique metadata nodes (16 fewer metadata instances): 7,710 unique total versus 7,711. The aggregate reuse decrease is therefore not a complete description of work, but neither the gate nor adequate cross-config reuse is satisfied.
  • ARM/Clang 9.2.0 took 2,020.134s (33m40s); six sequential planning-stage action-processing envelopes account for 1,604.567s (26m45s). The warm 9.1.0 run had 18,077 remote-cache hits and six remote executions, yet still took 722.677s. These are observed RBE runs, not controlled cold/native comparisons.
  • Current commit, post-inventory: Clang/9.2.0 builds all four actual family targets in 2,115.774s (35m16s), critical path 1,821.67s. Both source checks pass. The unchanged reuse gate fails: 7,842 instances, 7,710 unique nodes, 132 reused versus baseline 160 (1.68% versus 2.03%). Base/LZ4 share 6/1,240 typed compiler nodes; other pairs share zero. This is not a controlled cold run: 14,764 prior action-cache hits, 111 remote-cache hits and 7,673 remote executions. Snapshot/three guard/final replay action-processing envelopes are 289s / 322s / 340s / 387s / 470s, not CPU times.
  • Current commit, GCC/9.2.0 ARM: all three actual artifact/module tests pass, including the kernel artifacts and hello_c_module_armv7.ko; source fingerprint check passes. This is not a QEMU boot test. Elapsed 3,963.346s (66m03s), critical path 2,626.72s; 2,988 remote-cache hits and 7,474 remote executions. Initial Kbuild/snapshot/first guard/final replay action-processing envelopes are 741s / 796s / 809s / 951s. Correctness passes for this batch; the planning-performance objective remains unmet.

Still required

Remove repeated Make/lowering work across execution phases, establish useful broad cross-config reuse, qualify cold/native-comparable performance, and finish the actual GCC/Clang/SONiC/QEMU matrix on Bazel 9.1.0 and 9.2.0. An isolated relocated-plan checkpoint now combines compiler request/expression state with full final-family/observed-header replay, using fresh configured scopes and current result oracles. It preserves nil/empty request state without changing request IDs or registry collision checks. This remains research only and is not included in this commit: production carrier/action-input binding, phase wiring, real Linux checkpoint validation and performance evidence remain required. Leading current Clang scanner barriers include __signed__, _Pragma, __COUNTER__, generated config-name pasting and variadic comma semantics; they remain conservative, not hardcoded as safe.

The retained native Make reference and historical measurements below remain qualified observations, not a direct speedup ratio.

The isolated combined-checkpoint and malformed-shape suite passes both copied Kconfig test targets on 9.1.0 and 9.2.0. These use fixture compiler-result records, not an actual Linux checkpoint build or a speedup measurement; they are not part of this commit.


Previous checkpoint — actual family builds and reuse gaps, 2026-09-12

03941c271, still draft. No merge/release, baseline relaxation, or new output bases. The production source remains frozen during real ARMv7 and Clang-family qualification.

  • The actual GCC/Bazel 9.2 four-config build passes all four kernel targets, with unchanged source checks and disk caching disabled. It took 1,512.255s (25m12s), critical path 1,136.04s; 13,927 remote cache hits, 5,120 remote executions, and 2,598 local action-cache hits. This is a warm, overlapping RBE observation, not a cold/native speedup.
  • Its unchanged reuse gate fails: 7,850 node instances, 7,710 unique nodes, 140 reused instances versus baseline 155. Base/LZ4 still share 26/1,240 compiler nodes (2.09%). Compared with the preceding 146-instance result, the six fewer reused instances are exactly accounted for by removing two metadata nodes previously shared across all four variants; compiler sharing did not decrease.
  • The completed profile isolates the remaining planning problem: three guard-discovery actions take 320.716s, 348.364s and 397.977s (1,019.403s of recorded remote process time). Initial planning and final replay have no remote-process intervals in this run. Combined planning-action wall time is 1,125.928s, 74.45% of elapsed time. Cache reuse is not a substitute for meeting the cold-planning target.
  • Current Clang/Bazel 9.2 CI builds all four kernels, then fails reuse: 126 reused instances versus baseline 160, only 3 shared base/LZ4 compiler nodes versus floor 4, and 7,712 unique nodes versus baseline 7,686. Both Clang family CI lanes are red. The report identifies arch/x86/entry/vdso/vdso-note.o as precise in both base and LZ4 but assigned distinct final nodes; the cause is still under investigation. A local full Clang replay with targeted snapshot downloads is running.
  • All four current SONiC compiler/Bazel lanes and both root CI lanes have passed. The actual ARMv7 Clang/Bazel 9.1 artifact build has passed the initial snapshot stage and is still discovering reached-header guards; it is not yet a kernel pass or an ARM VM-boot result. Full matrix qualification remains incomplete.

Isolated, unintegrated work: immutable same-phase projection sharing passes the copied Kconfig suite on both Bazel versions, but still needs an actual planner benchmark. Real selected-compiler RBE experiments also show that compiling original C after removal of one unused config definition preserves fixture object bytes with -g0/-g on both GCC and Clang; GCC -g3 and Clang -fdebug-macro retain the unused macro in debug output. GCC emits a use trace with -dU, while the configured Clang explicitly ignores it. These are bounded feasibility results, not a production config-dependency proof or a universal compiler adapter.

Previous checkpoint — bounded ARM state frontiers, 2026-09-12

03941c271. Still draft: real current kernel/matrix validation, cold planning latency, native-comparable builds and useful cross-config reuse remain incomplete.

  • Reduce observed-state predecessor sets to their maximal same-path frontier. An ancestor already carried by a descendant is redundant and can make ordered writers appear unordered. Independent fork branches and every ordinary source-declared command prerequisite remain intact. Dense 64-node tests retain all 2,016 ordinary dependencies while reducing state edges to 63; transparent paths and reversed candidate ordering are covered.
  • Full production root suites pass 177/177 on Bazel 9.1 and Bazel 9.2, including formatting/Gazelle and unchanged source checks. Only the existing local nested-output-base test exclusion remains; CI retains it.
  • The real ARM planner replay passes with the original compiler-discovery artifacts and unchanged production snapshot format/limits. Inputs fall 3,146,804 → 259,958; observed-state references 3,132,738 → 245,892; uncompressed snapshot 665,761,693 → 181,690,685 bytes (73% smaller). Node, recipe, source and output counts are unchanged. The compressed snapshot is 30,270,601 bytes. Temporary replay/provider hooks are not in the PR.
  • This is a frontend replay, not a completed kernel build or a cold/native benchmark. It still takes 959.497s, so the planning-time goal is unmet. The actual Clang / Bazel 9.1 ARMv7 kernel and module artifact build is running. Despite the CI lane's QEMU title, its ARMv7 test checks ELF/zImage/config artifacts rather than booting a VM; other matrix lanes cover QEMU boots.
  • No snapshot limit, reuse threshold, source-selected compiler flag or warning policy was relaxed. The isolated environment-table codec remains unintegrated: it still exceeded ARM's limit before this structural fix. The preceding four-config reuse measurements below remain the latest completed family results, and still fail the unchanged reuse gate.
  • All local work uses CI RBE, disabled disk cache, minimal targeted downloads and existing default output directories. The complete matrix is being rerun on this revision. No merge or release.

Previous checkpoint — empty command selections and measured reuse, 2026-09-12

d611f20e359ffb56f69d3a69b275645cae1a4f75. Still draft: full current kernel/matrix validation, cold planning latency, native-comparable builds and useful cross-config reuse remain incomplete.

  • Compiler-command selection now uses the same target-context oracle in both passes to determine whether an exact source-selected occurrence becomes empty. The probe pass still retains symbolic command arguments and dependencies. No command-name or architecture exception was added, and nonempty occurrence/suffix correspondence checks remain strict.
  • A reduced source-owned findstring conditional reproduced the ARM vgettimeofday.o failure (one concrete versus two symbolic occurrences) before the fix. Full Kconfig tests cover discovery/replay request identity, repeated command names with different arguments, empty/whitespace middle occurrences, unresolved discovery, failed oracle answers and retained compiler-bearing mismatch rejection.
  • Fresh production root suites pass 177/177 on Bazel 9.2 and Bazel 9.1, including formatting/Gazelle and unchanged source checks. Only the existing local nested-output-base test exclusion remains; CI retains that test.
  • The actual Clang / Bazel 9.1 ARMv7 build with this fix failed later in snapshot serialization: 665,761,693 bytes exceeds the unchanged 536,870,912-byte limit. The previous command-selection mismatch was passed; this is not a successful ARM kernel build. Elapsed 2,322.495s; source check passes.
  • Local follow-up commits (not yet pushed) avoid redundant symbolic resolution when literal command text proves nonemptiness and add size-only diagnostics on snapshot overflow. Fresh root suites pass 177/177 on Bazel 9.2 and Bazel 9.1, including source checks and the same local nested-output-base exclusion. The actual ARM diagnostic run failed with the same snapshot overflow, with its source check passing. The breakdown is 398,246,782 bytes of nodes, 256,225,775 bytes of recipes, and about 11.3 MB of other fields; elapsed 2,102.583s. An isolated compact environment-table format passes bounded file round-trips for all four completed x86 snapshots with identical semantic bytes, but it is not yet integrated and is not a demonstrated solution to ARM's dominant node metadata growth. No size limit or reuse threshold was raised.

The completed GCC / Bazel 9.2 base, debug, BTF and LZ4 build on the preceding d3b255579 revision builds all four targets and confirms the private-output allocation fix:

  • Base/LZ4 shared compiler nodes: 5 → 26 of 1,240 (2.09%). The specific reboot.o pair now references one final action node with unchanged recipe and input-set identity.
  • Total node instances: 7,858; unique nodes: 7,733 → 7,712; reused instances: 125 → 146.
  • The unchanged reuse gate still fails: 146 reused instances versus baseline 155, and 185 basis points global reuse versus baseline 197. Each variant still has only 26 compiler nodes with precise config dependencies. Broader dependency precision remains unresolved.
  • Elapsed 2,949.957s (49m10s); critical path 1,920.98s; 18,657 remote executions. This is not a performance-goal success. Inputs were warm and runs overlapped; do not treat it as a controlled cold/native comparison or convert graph sharing into a runtime cache-hit claim.

The current published CI revision passes both root jobs, but all four x86 family jobs are red. Inspected Bazel 9.2 GCC and Clang logs confirm successful kernel builds followed by reuse-gate failures: GCC has 146 reused instances versus baseline 155; Clang has 133 versus baseline 160. Other matrix jobs remain running/queued. An isolated selected-compiler preprocessing experiment built 27 actions each with GCC and Clang over RBE: non-debug direct/split fixture objects match exactly, but debug metadata differs and GCC -g3 retains unused macros. This is only a feasibility experiment, not a production design change or kernel reuse result. Local qualification continues with CI RBE, disabled disk cache, minimal targeted downloads and existing default output directories. No merge or release.

Previous checkpoint — final private-output identity and ARM probes, 2026-09-12

d3b2555795a89eea946e74beb4a30d3a411ceca8. Still draft: current full-kernel/matrix validation, cold planning latency, native-comparable builds, and useful cross-config reuse are not complete.

  • Private compiler output allocations now follow the final projected inputs, rather than retaining an earlier full-config structural partition. A regression that previously produced two compiler actions for an unused config change now shares one, including an observed-state output, downstream consumer and persistent input-set edge. Relevant config changes, opaque compilers, noncanonical producers and non-owned paths remain separate. Final path hashing, writer provenance and executed-cut verification are unchanged.
  • Conditional non-compiler metadata suffixes retain their source-selected script when compiler-probe command counts differ. Compiler-bearing suffixes still require exact correspondence. This addresses the published GCC ARMv7 cmd_and_fixdep suffix failure; fresh actual GCC ARM qualification remains pending.
  • Bounded source-word analysis now understands private include roots and static shell quoting across optional argument fragments. It removes only proven-impossible source claims, without changing executable compiler argv or adding compiler/filename-specific exceptions. The actual Clang ARM run passed the formerly failing compiler-probe stage, then exposed a later command-selection mismatch in arch/arm/vdso/vgettimeofday.o; the kernel did not build.
  • Fresh complete root suites pass 177/177 on Bazel 9.2 and Bazel 9.1, including formatting/Gazelle and unchanged source checks. The existing local nested-output-base test exclusion remains; CI retains it.
  • The actual GCC / Bazel 9.2 base, debug, BTF and LZ4 build is still running. The actual Clang / Bazel 9.1 ARMv7 run failed in conservative family planning: arch/arm/vdso/vgettimeofday.o has one concrete compiler occurrence but two symbolic occurrences. Its source check passes; elapsed 1,154.087s, critical path 911.70s. This newly exposed mismatch remains unresolved. These are real artifact-build attempts, not graph-only checks; no current full-scale reuse improvement is claimed yet.

The latest completed pre-fix four-config GCC / Bazel 9.2 run, on f5e01c4bc, built all four targets but failed the unchanged reuse baseline: 5/1,240 base/LZ4 compiler nodes shared, 125 reused instances, 7,733 unique nodes. It took 2,899.424s with a 1,865.43s critical path. The final reboot.o comparison showed identical recipes and all 58 input markers, but different private output allocation paths; that evidence motivated the fix above. Other opaque macro-dependency cases remain and this fix alone does not establish the performance goal.

Local runs use CI RBE, disabled disk cache, minimal targeted downloads and existing default output directories. Inputs were warm and runs overlapped, so timings are not controlled cold/native comparisons. The previous published CI run finished with eight failures (four x86 family jobs and four ARM jobs); the full matrix is being rerun on this revision. No merge or release.

Previous checkpoint — deferred generated compiler inputs, 2026-09-12

40b034d9f. Still draft: actual ARMv7, full-matrix qualification, planning latency, and useful cross-config reuse remain incomplete.

  • Optional initial compiler-state queries now reject deferred generated-content tokens before registration, including tokens nested in source-owned Make/shell fragments and environment values. Actual executable compiler flags and generated-content actions are unchanged; no stack-guard offset is hardcoded.
  • Cached definedness and lexical witnesses now use the same source-normalized request identity as registration and scanning. Pending or differently projected answers cannot be borrowed, and witness lookup cannot register new queries.
  • Fresh complete root checks pass 177/177 on Bazel 9.2 and Bazel 9.1, including Buildifier/Gazelle and unchanged source checks. The existing local nested-output-base test exclusion remains; CI retains it.
  • The actual GCC / Bazel 9.1 ARMv7 run with these production fixes gets past initial compiler probes, then fails during conservative family planning: scripts/mod/empty.o has two concrete suffix commands but one compiler-probe suffix command. This is a newly exposed failure, not a successful kernel build. Source checks pass; the subsequent commit changes only test-input ordering. Separately, preceding-commit Clang ARMv7 CI reports a false mandatory scripts/recordmcount.c operand in a compiler-dollar-punctuation query; it is not yet diagnosed/fixed.

The completed family performance/reuse results below still qualify the preceding commit, not this one. A separate small-object RBE experiment found GCC -save-temps=obj objects byte-identical to ordinary compilation, but Clang objects differ: decoded instruction output matches while DWARF line-table paths/checksums differ. The experimental source is not in this PR, and this does not establish a production phase split or cross-config action reuse. No merge or release.

Previous checkpoint — module metadata and bounded RBE projection, 2026-09-12

af394b34e8e412636c4b23c9301a318d16238303. Still draft: corrected full ARMv7 and Bazel 9.1 large-kernel validation, the remaining matrix, planning performance, and useful cross-config reuse are incomplete.

  • Fixed module-source closure through persistent input sets, retaining exact producer/slot provenance for command metadata. The actual Linux 6.12 Clang/Bazel 9.2 RBE cell passes all 5 fresh tests: boot, ordinary module, MODVERSIONS module loading, metadata, and output builds. That run qualified dfaf53456, before the following two fixes. Its source fingerprint stayed unchanged.
  • Reproduced the remaining GCC and Clang ARMv7 source-claim failure with 32 conditional compiler flags. Source-word recognition now uses a bounded word automaton instead of enumerating exponentially many complete flag strings. Unsupported syntax retains conservative candidates; actual compiler argv and exact-occurrence validation are unchanged. Full discovery/replay and 3,645 small-language differential cases pass. Corrected actual ARMv7 CI is pending.
  • Replaced unbounded family facade actions with batches capped by file count and aggregate path length. Exact marker inputs and disjoint output ownership avoid Bazel 9.1's 4 MiB ActionResult limit without dropping 9.1 or adding client flags. Large/long-path registration, shared-parent projection, stale output, and symlink regressions pass; actual large-kernel 9.1 validation is pending.
  • Fresh root suites pass 177/177 on Bazel 9.2 and Bazel 9.1, including the fixes, Buildifier, and Gazelle. Both source checks pass. The local nested-output-base test exclusion remains unchanged; CI retains that test.

The completed GCC / Bazel 9.2 family run on this commit builds the actual base, debug, BTF and LZ4 targets successfully, but the unchanged reuse gate fails: only 5/1,240 base/LZ4 compiler nodes are shared (125 reused instances, 7,733 unique nodes). Elapsed time is 2,800.017 seconds (46m40s). Its completed profile records three reached-header guard-planning actions of approximately 334s, 354s and 403s, followed by 494s of final replay; initial per-config Kbuild discovery ranges from 50s to 89s. These are observed action-processing intervals, not CPU-only measurements or a controlled cold/native comparison. Exact final snapshots and source checks were retained. For a sampled precise assembly action, raw recipes, all 42 persistent input bindings and relevant config values match across base/LZ4; all 37 inherited state producers are already included in the executed cut. The remaining final-identity split is not yet explained, and matching raw inputs alone is not a cache-equivalence proof.

An actual ARMv7 GCC / Bazel 9.1 run on this commit exposed a subsequent failure: an optional compiler-state query receives a deferred generated-content token as a stack-protector offset. A local, uncommitted fix rejects such premature optional queries without changing executable compiler flags or inventing an offset; its Kconfig/proberun regression suites pass, but full ARM validation is still running. This is not fixed in the published commit yet. Local runs use CI RBE, disabled disk cache, and existing default output directories. No merge or release.

Performance-evidence correction: a retained September 10 native Make reference does exist; the earlier claim that none had been measured was incorrect. Rechecked phase logs show 3.460s base configuration, 50.155s fresh-object base image, 1.882s no-change image rebuild, 2.916s LZ4 configuration switch, and 6.078s LZ4 image update. Only 1 CC + 2 AS steps repeated for LZ4. Both native configuration comparisons reported zero symbol-value differences against their captured Bazel configurations; retained host/target manifests and configuration hashes match the recorded pins. This was a single local -j8, warm-filesystem reference using the earlier captured toolchain/configuration, not current four-config RBE qualification or a controlled cold-build comparison. Do not derive a direct speedup ratio from these unlike workloads.

Previous checkpoint — source prerequisites and RBE reports, 2026-09-12

de566e5fbdb5055866dafc79791fd9b7b1ada00a. Still draft: actual corrected ARMv7 validation, the remaining matrix failures, planning performance, and useful cross-config reuse are incomplete.

  • Reproduced the ARMv7 GCC failure in an actual local RBE kernel build. The retained request falsely claimed an included assembly prerequisite as a mandatory compiler argument. A bounded analysis of the authenticated argument fragments now removes only words absent from every finite literal possibility. Unknown text retains the conservative path. Actual compiler argv, source/header closure, and the runner's exact-occurrence checks remain unchanged. C/C++/assembly prerequisite, quoting, transform, budget, and full discovery/replay regressions pass; the corrected full ARMv7 kernel has not yet been validated.
  • Fixed CI report collection: requesting the reuse output group does not guarantee a local file with remote-output policies. The workflow now explicitly downloads only *.reuse-report.json. With the CI RBE configuration, the same mapped-kernel fixture build left the report absent before the change and materialized it afterward. The reuse gate and its thresholds are unchanged.
  • Fresh full local root suites pass 177/177 on Bazel 9.2.0 and Bazel 9.1.0, with unchanged source fingerprints and the existing local nested-output-base test exclusion. The complete Kconfig and proberun packages also pass freshly.
  • Added immutable source lookup for compiler header scanning and request-local source-root normalization. An isolated 128-word RBE microbenchmark measured about 26.2× faster normalization and 89.7% fewer allocated bytes; this is not a kernel-planning, cold-build, or cross-config-reuse speedup.

The preceding CI revision built the four x86_64 example families successfully but failed report collection; its Linux 6.12 MODVERSIONS test additionally exposed a missing staged module source during modpost. One Aya job failed with an RBE keepalive error. Both host-platform jobs passed. These are observations of the preceding revision, not current full-matrix qualification. The poor reuse/planning measurements below remain the latest full-family performance evidence. No merge or release.

Previous checkpoint — ARM64 KVM probe fix, 2026-09-12

Pushed 1fd388f6da1341b16c9e4b467588406d109fabc6. Still draft: full matrix, planning performance, and useful cross-config reuse remain incomplete.

  • Reproduced the ARM64 nVHE CI failure with the exact KVM config over RBE. The probe retained .../nvhe/../fpsimd.S but expected the canonical source path. Source-operand recognition now accounts for literal dot segments, without changing actual compiler argv, option payloads, or the runner's exact-occurrence checks. Unresolved symbolic words cannot be mistaken for literal source operands.
  • Fresh complete local root suites pass 177/177 on Bazel 9.2.0 and Bazel 9.1.0, with the same local nested-output-base test exclusion described below.
  • The actual corrected ARM64 KVM-config kernel build passes with Clang/Bazel 9.2, CI RBE, disabled disk cache and the existing default examples output directory. This builds the nVHE objects, vmlinux and boot image, not just the graph. Elapsed 955.570s, critical path 403.03s, 2,761 remote executions; source fingerprint checks pass. Prerequisites were warm and another build ran concurrently, so this is not a cold/native performance comparison. The temporary exact KVM/allnoconfig example substitutions were restored afterward and are not part of the commit.
  • Extracted a workload-bound compiler-query context as groundwork for discovery transport. Twelve pre-refactor canonical request/dependency identities and mutation-isolation tests pass. This does not yet serialize the context, eliminate repeated Kbuild evaluation, or prove a speedup.

CI is being rerun for this commit. The prior checkpoint's performance/reuse measurements below remain the latest measurements, not qualification of this revision. No merge or release.

Previous checkpoint — 5ba9da4, 2026-09-12

Pushed 5ba9da4ab59f7fb874a49d093d882a1568584527. This remains a draft: cross-config reuse and planning performance are not yet adequate. No merge or release is intended.

  • Fresh root checks pass 177/177 on Bazel 9.2.0 and Bazel 9.1.0. Locally, only //internal/tests/source_repo:source_repo_test is excluded because it creates additional Bazel output directories; it remains enabled in CI. Buildifier and Gazelle now pass.
  • Actual SONiC linux_ngbde.ko, vendor Kconfig enablement, and ARM64 exclusion tests pass in all four cells: GCC / 9.2, Clang / 9.2, GCC / 9.1, Clang / 9.1.
  • The actual GCC / Bazel 9.2 base, debug, BTF and LZ4 family build succeeds, but the unchanged reuse gate fails: 7,858 variant node instances, 7,733 unique nodes, 125 reused instances; base/LZ4 share only 5 of 1,240 compiler nodes. This is not sufficient cross-config reuse.
  • That family run took 2,445.592 seconds (40m45.6s), with 1,743.518 seconds in observed planning intervals. Initial planning prerequisites were warm and other builds ran concurrently: these are observational numbers, not a cold-cache speedup or native-build comparison. See the corrected retained native reference above.
  • These local runs use the CI RBE configuration, disabled disk artifact caching, minimal downloads, and existing default output directories. Kernel/SONiC results precede only the whitespace-only fixture BUILD correction; the root results include it. Remaining QEMU/Aya and complete CI-matrix qualification is still pending.

The checkpoint includes bounded compiler-guard discovery, fresh source/compiler replay, content-addressed configuration capsules, real compiler diagnostic regressions, module metadata validation, and the reuse regression checker. Unsupported dependency proofs retain conservative inputs. No compiler-specific capability values, baseline relaxation, or warning suppression was added to make the reuse result pass.

Summary

  • replace the repository-generated Kconfig/Kbuild graph with a Bazel 9 map_directory pipeline
  • probe the selected target and host compiler toolchains as Bazel actions, then replay Kconfig and Kbuild from those measured capabilities
  • lower the source-selected C, assembly, Rust, host-tool, objtool, kernel, and external-module actions into hermetic action plans
  • remove the generated BUILD graph, hard-coded compiler-capability tables, Kconfig prebuilt release machinery, and the old per-architecture object-rule stack
  • exercise the existing kernel/module suites with Bazel 9.1.0 and 9.2.0 under both Clang and GCC, including the SONiC linux_ngbde module

Design

Repository evaluation only discovers source inputs and declares the map_directory stages. Compiler, assembler, linker, archive, binary-tool, pkg-config, and source-script probes run with the selected Bazel toolchains. Their typed results drive Kconfig resolution, Kbuild traversal, generated-content queries, action selection, and exact source/object-tree frontiers.

The resulting plans preserve the selected toolchain and execution-platform identity, carry only declared source/tool/generated inputs, and fail closed when a command or compiler-derived value cannot be represented hermetically. External modules use the same Kconfig/Kbuild path as in-tree targets, including module SDK state, generated headers, modpost, source versions, and generated .mod.c compilation.

This is a complete cutover: there is no repository-generated compatibility graph and no hard-coded Clang or GCC capability model left in the build API.

Validation from the previous checkpoint

These older results describe the previous PR revision, not full qualification of the current checkpoint above.

  • bazel test //...: 68/68 tests pass with Bazel 9.1.0
  • bazel test //...: 68/68 tests pass with Bazel 9.2.0
  • Linux 6.18 x86_64 GCC kernel plus five module/e2e tests: BuildBuddy
  • Linux 6.18 x86_64 GCC with Bazel 9.1.0: BuildBuddy
  • Linux 6.18 x86_64 Clang with Bazel 9.2.0: BuildBuddy
  • standalone examples with Bazel 9.2.0: Clang, GCC
  • previous PR CI: GitHub Actions

The PR remains draft while the full Clang/GCC and host-platform matrix completes and the reuse/performance gaps are addressed.

@fionera fionera changed the title Prototype action-time Kconfig graph expansion with map_directory Prototype action-time toolchain-driven Kconfig with map_directory Aug 12, 2026
@fionera
fionera force-pushed the agent/map-directory-kconfig-spike branch from 6f412d1 to 5211a02 Compare August 12, 2026 21:53
@fionera fionera changed the title Prototype action-time toolchain-driven Kconfig with map_directory Prototype compiler-aware Kconfig and Kbuild with map_directory Aug 12, 2026
@fionera fionera changed the title Prototype compiler-aware Kconfig and Kbuild with map_directory Kconfig: evaluate compiler-selected Kbuild dynamically with map_directory Aug 27, 2026
fionera added 14 commits August 27, 2026 16:30
Carry source-selected compiler queries through bounded guard discovery and
fresh replay; derive content-addressed config capsules and retain conservative
inputs whenever complete source/compiler dependency coverage is unavailable.

Add real GCC/Clang family, intrinsic, macro-diagnostic and module metadata
coverage, plus SONiC and QEMU matrix wiring and unchanged reuse regression gates.
Include the optional-definedness BUILD formatting correction.

This is an incomplete draft checkpoint: actual four-kernel and SONiC builds
pass, but base/LZ4 sharing is only 5/1240 compiler nodes and the reuse gate fails.
Planning latency and the remaining full CI matrix still need work. No release
or merge is intended.
Pin twelve pre-refactor request and ordered-dependency identities across literal, symbolic and source-shell inputs. Preserve the single-use construction path without an extra deep copy; reusable contexts own their mutable request data.

This is groundwork for discovery context transport, not a serialized handoff or a performance completion claim. Both Bazel root suites pass with the local nested-output-base test excluded.
Reproduced the ARM64 nVHE CI failure with the exact KVM allnoconfig: the literal ../fpsimd.S operand did not match its canonical source edge. Normalize only literal positional path identities before optional probe construction, preserve option/placeholder ownership, and keep the runner's exact occurrence check unchanged.

Both Bazel root suites pass locally (177 tests each, nested-output-base test excluded). The real Clang KVM build now passes the initial probe stage; full kernel/matrix and performance validation remain pending. Temporary example reproduction edits are excluded.
@fionera

fionera commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

Published checkpoint — 2026-09-13 13:10 UTC: f06cb1ec7. This PR remains draft; nothing was merged or released.

This checkpoint ranks complete weak-hint closures by distinct consumers, adds bounded literal-header grammar discovery, preserves binding-probe capacity by separating speculative grammar from entered definitions, and handles ordinary identifier/literal adjacency used by Linux stringification macros. Grammar promotion keeps one executable attempt per compiler context; source facts still require measured answers. No compiler-family behavior tables, extra rounds, larger limits, or relaxed reuse thresholds were added.

Exact source 587ba0869… passed, using CI RBE, --disk_cache= and default output bases only:

  • Root 177/177 on Bazel 9.2 and 9.1. The local nested-output-base test remains excluded; CI retains it.
  • Actual compiler fixtures: GCC/9.2, Clang/9.2, GCC/9.1, Clang/9.1: all pass, including independent compiler/object-byte measurements, sharing and invalidation.
  • Four actual Clang/9.2 kernels: build passed, reuse gate failed. Compile-only reuse is 6/5,062 instances (0.12%). Across all node kinds, reuse is 132/7,842 (1.68%), with 7,710 unique nodes and 48 shared nodes. This restores the intermediate 5-compile regression but does not improve the original baseline.

The four-kernel run took 1,429.533 s (23m50s), with 24,436 remote-cache hits and 20 remote executions. No other owned local RBE job or published CI run overlapped it, but this is still a mostly cached workload, not a cold/native comparison. Completed remote-process wall times: initial planning ~267 s, guard rounds ~136/173/203 s, final verification ~241 s. Broad cross-config sharing, couple-minute cold planning and native-comparable builds remain unmet.

The previous checkpoint's CI finished 64 successes and four reuse-gate failures after successful kernel builds. This new checkpoint still needs its full CI matrix; older SONiC/QEMU results do not prove coverage of this source. Both Bazel versions and both compilers remain in CI.

Historical checkpoints follow; their descriptions and coverage apply to their own source versions:

Published checkpoint — 2026-09-13: 2a9ecbda4. PR remains draft; nothing was merged or released.

This checkpoint measures empty variadic-comma behavior with the selected compiler, preserves forward macro rescans, and retains bounded complete weak-hint query closures. Missing/rejected measurements remain conservative; no compiler-family behavior table or relaxed reuse threshold was added.

Qualification of the exact published source (09d8d979…), using CI RBE, --disk_cache= and only default output bases:

  • Root: 177/177 on Bazel 9.2 and 9.1. The local test that creates additional output bases remains excluded; CI retains it.
  • Actual mapped compiler fixtures: GCC/9.2, Clang/9.2, GCC/9.1, Clang/9.1: all pass, including compiler identity, independent grammar/object references and sharing/invalidation assertions.
  • Four actual Clang/9.2 kernels: build passed, reuse gate failed. 132/7,842 reused planned-node instances (1.68%), 7,710 unique nodes and 48 shared nodes. This total includes compilation, generation, copying and metadata; compile-only reuse is 6/5,062 instances (0.12%), with only six precise compile memberships per variant. This matches the original baseline; it does not improve production reuse.

The four-kernel run took 1,423.905 s (23m44s) with 24,435 remote-cache hits and 12 remote executions. It is mostly cached evidence, not a cold/native comparison. Completed remote-process wall times were ~272 s for initial family planning, ~137/162/201 s for guard rounds and ~225 s for final replay. Bazel 9.1/9.2 critical-path reporting has an action-template dependency gap; elapsed minus reported critical path must not be treated as client overhead.

Partial hint retention repairs an intermediate 131-instance regression but still omits frequently needed query vectors. Consumer-frequency scheduling is the next investigation, not an implemented gain. The full SONiC/QEMU matrix has not been rerun on this exact checkpoint; older results below do not establish current-source coverage. Broad reuse, couple-minute cold planning and native-comparable builds remain unmet. Both Bazel versions and both compilers remain in CI.

Historical worktree and published checkpoints follow:

Local validation update — 2026-09-13 (unpublished worktree; the PR head is still a99bb13c7, and the PR remains draft).

The bounded counter-query selection and wider macro-call support passed root tests and the actual compiler fixtures. They also passed the full SONiC module matrix on GCC/Clang × Bazel 9.1/9.2, and all seven x86 Clang/9.2 kernel, QEMU, module, MODVERSIONS and SRCVERSION tests. These are worktree 972f8bff… results, not additional published-commit coverage.

The actual four-config kernel build succeeded, but the unchanged reuse gate still fails at 132/7,842 reused instances (1.68%), with 7,710 unique nodes. Counter prefetch reduced missing-counter fallbacks from 329 to 109 base compiles, but 220 now stop at an unmeasured generated identifier; broader sharing did not improve. Elapsed 1,527.611 s with 21,277 remote hits and 3,131 remote executions is mixed-cache evidence, not a controlled cold/native speedup.

A fresh bounded CPU capture exposed duplicate request validation/encoding. The subsequent unpublished worktree 3c721164… hashes the already validated canonical bytes instead. It passes root 177/177 on both Bazel versions and all four actual mapped-compiler fixtures, including identity, sharing, invalidation and independently compiled-byte checks. A five-repeat RBE microbenchmark reduced median canonical-plus-ID processing from 3.97 ms to 2.96 ms (~25%); this is only that operation, not whole-planner or kernel-build performance. Full-kernel timing of this last optimization remains unmeasured.

CI RBE, disabled action disk cache and default output directories were retained. Broad cross-config reuse, couple-minute cold planning and native-comparable builds remain open. No gates were weakened, and nothing was merged or released.

Historical published checkpoints follow (the running jobs mentioned below have since completed):

Latest checkpoint: a99bb13c7 handles supplied variadic-only GNU comma-paste tails without assuming how an ambiguous empty call behaves. Actual GCC/Clang object checks cover populated, expanded-empty, separator-only and named tails, plus conditional CONFIG dependencies. Empty calls remain fail closed. This PR remains draft, not ready to merge.

Using CI RBE, no action disk cache, and the existing default output directories, production source 7400595a… passed:

  • Root 177/177 on Bazel 9.2 and 9.1, with the unchanged local-only nested-output-directory test exclusion.
  • The actual mapped-compiler fixture on GCC/9.2, Clang/9.2, GCC/9.1, and Clang/9.1, including compiled-byte, sharing and invalidation assertions.

The actual four-config Clang/9.2 kernel build succeeded, but the unchanged reuse gate still fails at 132/7,842 saved instances (1.68%), with 7,710 unique nodes. Elapsed 1,369.762 s, 22,040 remote-cache hits and 18 remote executions: this is a warm-cache result, not a cold/native comparison. Completed process wall times were 277.682 s for the cut and 244.007 s for final replay. No overall planning speedup or reuse gain is established.

The 117 base compile actions formerly stopped at COUNT_ARGS now reach the next limitation, __COUNT_ARGS' formal-argument budget. The 329 missing-counter-state failures are unchanged. Earlier counter availability/value hints, lower-priority admission and authenticated optional attempts have passed isolated tests on both Bazel versions, but that prototype is not included in this commit and still needs actual compiler/build integration validation. A GCC/9.1 x86 QEMU/module/MODVERSIONS/SRCVERSION batch is running, not yet reported as passed.

Broad reuse, couple-minute cold planning and native-comparable builds remain unmet. No thresholds were relaxed; nothing was merged or released.

Previous counter checkpoint: 3fee31654 integrates compiler-measured counter sequences into source closure analysis. Values come from authenticated configured-compiler probes, with ordered branch/TU state and fail-closed exhaustion. No compiler-family values, extra discovery rounds, or relaxed reuse thresholds were added. This PR remains draft, not ready to merge.

With CI RBE, no action disk cache and only the existing default output directories:

  • Final source f548e2d5… passed 177/177 root tests on Bazel 9.2 and 9.1, with the same local-only nested-output-directory test exclusion. CI retains that test.
  • The same production code before the README-only update passed the actual mapped-compiler fixtures for GCC/9.2, Clang/9.2, GCC/9.1, and Clang/9.1. Counter object bytes are checked against an independent configured-compiler object, not hardcoded expectations.
  • SONiC 2/2 in all four cells, building the actual linux_ngbde module and kernel: GCC/9.1, GCC/9.2, Clang/9.2, Clang/9.1.
  • x86 Clang/9.2 7/7, including actual QEMU boot, module loading, MODVERSIONS and SRCVERSION coverage. This is not a rerun of the full QEMU matrix.

The actual four-config Clang/9.2 kernel build passed, but the unchanged reuse gate still fails at 132/7,842 saved instances (1.68%). Total elapsed 2,105.827 s with mixed remote-cache hits/executions; this is not a cold/native performance comparison. Completed planner process wall times were about 280 s for the cut and 242 s for final replay. No overall planning or reuse improvement is established.

The real-kernel query manifests contain no counter-sequence requests in the three discovery rounds, even though final source replay now recognizes the counter binding and reports missing exact state. Earlier bounded query discovery remains necessary. Broad cross-config reuse, couple-minute cold planning and native-comparable builds remain unmet. Nothing was merged or released.

Workspace cleanup removed unused repository-cache data, increasing available disk space from about 11 GiB to 29 GiB; active unpacked repositories and default output directories were preserved. The old action disk cache was already absent.

Previous checkpoints (historical results):

Latest update: 958ff7ac6 adds a lazy, closure-local inverse index for materialized producer ownership. Exact pathname owners and the original ordering/error checks are preserved. This PR remains draft, not ready to merge.

Production source 5a1fa410…, using CI RBE with disk cache disabled, passed root 177/177 on both Bazel versions, all four GCC/Clang × Bazel 9.1/9.2 actual mapped-compiler fixtures, and ARMv7/GCC/9.1 kernel plus external-module artifacts 3/3. The ARM lane builds the real .ko; it is not a QEMU boot.

The four-config Clang/9.2 build succeeded. Its reuse report is byte-for-byte unchanged: 132/7,842 saved instances (1.68%), and the existing reuse gate still fails. No baseline was lowered. Completed process timings show no material x86 planner speedup (267 s cut, 241 s final replay). ARM initial Kbuild planning measured 1,065 s versus 1,108 previously; this is one comparison, not an established overall speedup. Different remote-cache populations make total build elapsed times unsuitable for a controlled comparison.

The compiler-measured counter-state work remains an isolated prototype, not part of this commit. Query transport, runner argument validation and detached answer replay/merge are being tested before production scanner integration. Broad reuse, couple-minute planning and native-comparable builds remain unmet. Nothing was merged or released.

Previous checkpoint: 2f3fa4c89 uses sparse per-query producer visitation without changing reachability, error ordering, retained-cache scope or sharing policy.

Production source 2917eab1…, using CI RBE and no disk cache, passed:

The actual four-config Clang/9.2 build succeeded, but the unchanged reuse gate still fails. Its report is byte-for-byte identical to the previous production report: 132/7,842 saved instances (1.68%), 7,710 unique nodes and only 6/1,240 typed compiles shared between base/LZ4. Elapsed 1,349.699 s, with 22,046 remote-cache hits and 12 remote executions; not a cold/native comparison.

Same-process traversal microbenchmarks roughly halve the clustered case's time and reduce its allocations from 7.18 MB to 0.277 MB per batch; sparse queries also improve. This is not an established kernel speedup. Completed Clang planner process times remain roughly 267 s for the cut, 134/146/194 s for guard rounds, and 243 s for final replay. ARM initial Kbuild planning still took about 1,108 s. The couple-minute planning goal and broad cross-config reuse are unmet. An owner-lookup optimization and compiler-measured counter experiment remain isolated, not included in this commit. No thresholds were relaxed and nothing was merged or released.

Earlier checkpoints:

Previous production changes were pushed as 92f89e9ab, following checkpoint fixes in 0c30b6246.

CI cache-policy commit 3e826294e disables restored action disk caches and explicitly passes --disk_cache= to builds/tests and the matching reuse query. Existing RBE, download caches, and GCC/Clang × Bazel 9.1/9.2 matrix are retained. Both workflows pass actionlint. The preceding Windows job failed with Permission denied in D:/_bazel-disk/cas/ while staging glibc; the new Windows and macOS workflow has now passed both jobs.

The v4 checkpoint interns repeated compiler-query stdin without raising the 64 MiB wire limit, restores exact request identities, and bounds expanded validation work. Replay now recomputes dependency-only Make reductions from the current oracle even when their symbolic aliases were pruned. Immutable source inventories and bounded query-program text are shared without caching compiler answers or replacing the restored input-set store.

Verified on production source 1695e85f9b24201ee518b695c4b5cda6b2dc01ee04b949774982a44bb68367d9, with CI RBE, disk cache disabled and existing default output directories:

  • Root: 177/177 on Bazel 9.2 and 9.1. Only the existing local nested-output-directory test exclusion remains; CI retains it.
  • GCC / 9.2 Aya: 11/11, including actual aarch64 and x86 kernel/VM runs. Elapsed 2,040.746 s, critical path 1,011.39 s.
  • GCC / 9.2 Linux 6.18 x86: 7/7, including kernel outputs, QEMU boot and module loading, SRCVERSIONS, and MODVERSIONS outputs/metadata/module loading. Elapsed 2,287.873 s, critical path 1,181.45 s.
  • All source-integrity receipts passed. These actual runs qualify the previously failing pure-replay and checkpoint-size paths; they do not qualify the entire compiler/Bazel/QEMU matrix.

Performance and broad cross-config reuse remain open. The preceding four-config Clang run built all actual targets, but its unchanged reuse gate failed: 7,710 unique nodes and 132 reused instances (1.68%), against floors of 160 and 2.03%. Its 1,357.492 s elapsed time was warm-cache evidence, not a controlled cold/native comparison. The published checkpoint's GCC CI lane also missed its reuse floors (140 versus 155 instances, 1.78% versus 1.97%).

Before the final paste change, the allocation/pragma follow-up removed unnecessary query-validation/digest copies and let complete ordered macro-call proof distinguish discarded/stringified pragma arguments from executed effects. Production source 84485b3… passed root 177/177 on both versions, Clang/9.1 kernel/QEMU/MODVERSIONS 7/7, and actual SONiC module tests 2/2 with GCC/9.1 and Clang/9.2. Its four-config Clang build succeeded but still failed the unchanged reuse gate at 132 instances/1.68%. Completed planning-action envelopes were about 4–9% shorter than the preceding run; overall elapsed time was 2,130.464 s with a different cache mix, not a controlled cold/native speedup.

The latest published source additionally handles valid token pasting of self-suppressed operands. A real GCC fixture first compiled correct bytes but failed precise sharing, then passed after the fix; an independent compiler object and all three family images check the emitted byte while existing sharing/invalidation assertions remain.

Current production source 80db118… passed root 177/177 on 9.2 and 9.1, plus the actual mapped-family fixture with GCC/9.2, Clang/9.2, GCC/9.1, and Clang/9.1. Actual compiler identities and source-integrity checks passed.

The current four-config Clang/9.2 build built all four actual kernel targets. Its unchanged reuse gate still fails: 132/7,842 reused instances (1.68%), with only 6/1,240 typed compiles shared between base and LZ4 and zero between the other pairs. Elapsed 1,363.846 s, critical path 1,096.71 s; 22,048 remote-cache hits and 13 remote executions. This heavily cache-warm run also requested a separate guard CPU diagnostic; it is not a controlled cold/native comparison. The fresh guard sample attributes substantial CPU to dependency analysis and garbage collection. The two Clang examples CI failures reproduce these same reuse-floor violations, not a kernel compilation failure.

Current Aya/Clang/9.1 passed 11/11, including actual aarch64 and x86 kernel/VM tests. Elapsed 1,815.946 s, critical path 919.55 s. ARMv7/GCC/9.1 also passed 3/3, building the actual kernel and external module and checking artifacts (not an ARM QEMU boot in this local lane). Elapsed 2,490.037 s, critical path 1,186.06 s. Source-integrity checks passed; these runs used RBE with no disk cache.

The published main CI run is complete: 62 jobs passed, four failed. All four failures are the GCC/Clang × Bazel 9.1/9.2 examples reuse gates described above; their kernel builds succeeded. Broad reuse and cold/native performance targets remain unmet. No thresholds were relaxed, and nothing was merged or released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant